package com.example.service.impl;

import com.example.entity.DetailsLogs;
import com.example.entity.Page.MyPageHelper;
import com.example.entity.Page.PageRequest;
import com.example.mapper.DetailsLogsMapper;
import com.example.result.CommonResult;
import com.example.service.DetailsLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author: tobed
 * @date: 2022/11/17
 * @time: 18:54
 */
@Service
public class DetailsLogsServiceImpl implements DetailsLogsService {

    @Autowired
    DetailsLogsMapper detailsLogsMapper;

    /*全查方法*/
    @Override
    public CommonResult list(PageRequest pageRequest, DetailsLogs detailsLogs) {
        Example example = new Example(DetailsLogs.class);
        MyPageHelper.startPage(pageRequest);
        if (!detailsLogs.getOperateUser().isEmpty()){
            example.createCriteria().andLike("operateUser","%"+detailsLogs.getOperateUser()+"%");
        }
        if (!detailsLogs.getOperateDetails().isEmpty()){
            example.createCriteria().andEqualTo("operateDetails",detailsLogs.getOperateDetails());
        }
        List<DetailsLogs> list = detailsLogsMapper.selectByExample(example);
        return CommonResult.ok(MyPageHelper.getPageResult(list));
    }
}
